import Vue from 'vue'
import Router from 'vue-router'
import systemRoute from './modules/system'
import PlanRoute from './modules/plan'
import UserRoute from './modules/user'
import MoneyRoute from './modules/money'
import CountRoute from './modules/count'
import BranchRoute from './modules/branch'
import AppConfigRoute from './modules/appConfig'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/dashboard'
    },
    {
      path: '/',
      component: resolve => require(['../components/common/Home.vue'], resolve),
      meta: { title: '自述文件' },
      children: [
        {
          path: '/dashboard',
          component: resolve =>
            require(['../components/page/home/Dashboard.vue'], resolve),
          meta: { title: '首页' }
        },
        ...systemRoute,
        ...PlanRoute,
        ...UserRoute,
        ...MoneyRoute,
        ...CountRoute,
        ...BranchRoute,
        ...AppConfigRoute,
        {
          path: '/404',
          component: resolve =>
            require(['../components/page/error/404.vue'], resolve),
          meta: { title: '404' }
        },
        {
          path: '/403',
          component: resolve =>
            require(['../components/page/error/403.vue'], resolve),
          meta: { title: '403' }
        }
      ]
    },
    {
      path: '/login',
      component: resolve => require(['../components/page/Login.vue'], resolve)
    },
    {
      path: '*',
      redirect: '/404'
    }
  ]
})
